package com.study.Config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 描述: 资源服务器配置
 * 用户获取资源的最后一步，资源服务器对用户访问资源的放行
 * @author Ychiha
 * @version 1.0
 * @date 14/1/2022 下午6:36
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    /**
     * 重写参数为HttpSecurity的configure方法
     * 与Security配置差不多，是对资源的放行管理
     * @param http
     * @throws Exception
     */
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest()
                .authenticated()
                //通过and，可以只写一次http，通过and来进行链接
                .and()
                .requestMatchers()
                .antMatchers("/user/**");
    }
}
